"""
FIVEDASH(TM) -- General Purpose Accounting Software
Copyright (C) 2008  Obol Software Pty Ltd

This program is free software: you can redistribute it and/or modify
it. For terms and conditions, see fivedash/license/license.txt

"""

from mod_python import apache
from mod_python import Session
from mod_python import util

def index( req ):
		session = Session.Session(req,timeout=3600)
		s = '------------request-------------\n'
		s += '%-30s:%s\n' % ('config',req.get_config())
		s += '------------session-------------\n'
		s += '%-30s:%s\n' % ('id',session.id() )
		s += '%-30s:%s\n' % ('create_time',session.created() )
		s += '%-30s:%s\n' % ('last_accessed',session.last_accessed() )
		s += '%-30s:%s\n' % ('time_left',session.last_accessed() - session.created() )
		if session.last_accessed() - session.created()>3599:
				s += '%-30s\n' % ('reset session timeout')
				session.set_timeout(3600)
		s += '%-30s:%s\n' % ('timeout',session.timeout() )
		s += 'content: \n'
		for key in session.keys():
				s = s + '\t%-50s:%s\n' % (key,session[key])
		s = s + '---------request--------------\n'
		form = util.FieldStorage(req)
		for f in form.keys():
				s = s + '\t%-50s:%s\n' % (f,form[f])
		s = s + '--------other------------------\n'
		import os
		s = s + "path_info:%s\n" % req.path_info
		s = s + "canonical_filename:%s\n" % req.canonical_filename
		s = s + "document_root():%s\n" % req.document_root()
		return s
